package com.example.demo.ui.main;

import android.content.Context;

import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.demo.R;
import com.example.demo.ui.dashboard.DashboardFragment;
import com.example.demo.ui.home.HomeFragment;
import com.example.demo.ui.home.MainFragment;
import com.example.demo.ui.notifications.NotificationsFragment;

/**
 * A [FragmentPagerAdapter] that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {


    private static final String[] TAB_TITLES = new String[]{"登录", "购物"};
    private final Context mContext;
    private static final Fragment[] fragments = new Fragment[]{
            new MainFragment(),
            new DashboardFragment(),
            new NotificationsFragment()

    };

    public SectionsPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        mContext = context;
    }

    //返回当前对应的 Fragment
    @Override
    public Fragment getItem(int position) {

        return fragments[position];
    }

    //返回对应分类文本
    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {

        return TAB_TITLES[position];
    }

    @Override
    public int getCount() {
        // Show 2 total pages.
        return TAB_TITLES.length;
    }


}